---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.1.log
  log type:  text
 opened on:  12 May 2025, 17:45:06

. 
. use "C:\Users\sbstjp\OneDrive - Cardiff University\anes_timeseries_2020_stata_20220210.dta" // American Natio
> nal Election Study 2020 Time Series Study, Feb 10, 2022 Version. Date accessed: March 09, 2025. Accessed from
>  https://electionstudies.org/data-center/2020-time-series-study/

. 
. // Social justice scale 
. *Delete missing values
. rename V201411x tgpolicy 

. replace tgpolicy = . if tgpolicy == -2
(313 real changes made, 313 to missing)

. rename V201626 offence 

. replace offence = . if inlist(offence, -5, -9)
(176 real changes made, 176 to missing)

. rename V202183 metoo 

. replace metoo = . if inlist(metoo, -9, -7, -6, -5, -4, 998, 999)
(2,122 real changes made, 2,122 to missing)

. rename V202174 blm 

. replace blm = . if inlist(blm, -9, -7, -6, -5, -4, 998, 999)
(936 real changes made, 936 to missing)

. 
. *Reverse code offence so social justice values are high
. egen maxval = max(offence)

. gen roffence = maxval + 1 - offence
(176 missing values generated)

. drop maxval

. 
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in tgpolicy roffence metoo blm {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
    tgpolicy |      7,967    3.470692    2.007609          1          6
(313 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
    roffence |      8,104    2.429911    1.106463          1          4
(176 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       metoo |      6,158    59.02891    29.87323          0        100
(2,122 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
         blm |      7,344    53.29562    35.43163          0        100
(936 missing values generated)

. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in stgpolicy sroffence smetoo sblm  {
  2.     replace `var' = 0 if missing(`var')
  3. }
(313 real changes made)
(176 real changes made)
(2,122 real changes made)
(936 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreSJV = 0

. gen count_nonzeroSJV = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in stgpolicy sroffence smetoo sblm  {
  2.     replace total_scoreSJV = total_scoreSJV + `var'
  3.     replace count_nonzeroSJV = count_nonzeroSJV + (`var' != 0)
  4. }
(7,967 real changes made)
(7,967 real changes made)
(8,104 real changes made)
(8,104 real changes made)
(6,158 real changes made)
(6,158 real changes made)
(7,344 real changes made)
(7,344 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen socJusValues = .
(8,280 missing values generated)

. replace socJusValues = total_scoreSJV / count_nonzeroSJV if count_nonzeroSJV > 0
(8,262 real changes made)

. 
. // Liberalism scale
. *Delete missing values
. 
. rename V201415 gayadopt

. replace gayadopt = . if inlist(gayadopt, -8, -9)
(128 real changes made, 128 to missing)

. rename V201336 abortion

. replace abortion = . if inlist(abortion, -8, -9, 5) 
(380 real changes made, 380 to missing)

. rename V201262 environment

. replace environment = . if inlist(environment, -9, -8, 99)
(1,156 real changes made, 1,156 to missing)

. rename V202232 immigration

. replace immigration = . if inlist(immigration, -9, -8, -7, -6, -5) 
(930 real changes made, 930 to missing)

. rename V201345x deathpen

. replace deathpen = . if inlist(deathpen, -2) 
(167 real changes made, 167 to missing)

. rename V201426x wall

. replace wall = . if inlist(wall, -2) 
(40 real changes made, 40 to missing)

. rename V201308x bordersec

. replace bordersec = . if inlist(bordersec, -2) 
(53 real changes made, 53 to missing)

. rename V201311x crime

. replace crime = . if inlist(crime, -2) 
(54 real changes made, 54 to missing)

. 
. *Reverse variables so liberalism coded high
. foreach var in gayadopt immigration environment {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }
(128 missing values generated)
(930 missing values generated)
(1,156 missing values generated)

. 
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in rgayadopt abortion renvironment rimmigration deathpen wall bordersec crime {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
   rgayadopt |      8,152    1.803974    .3970124          1          2
(128 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
    abortion |      7,900    3.045696    1.090679          1          4
(380 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
renvironment |      7,124    4.917462    1.981363          1          7
(1,156 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rimmigration |      7,350    3.008435    1.137414          1          5
(930 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
    deathpen |      8,113    2.175521    1.151282          1          4
(167 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        wall |      8,240     4.29551    2.473342          1          7
(40 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
   bordersec |      8,227    2.646651    1.344673          1          5
(53 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       crime |      8,226    2.269998    1.162187          1          5
(54 missing values generated)

. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in srgayadopt sabortion srenvironment srimmigration sdeathpen swall sbordersec scrime {
  2.     replace `var' = 0 if missing(`var')
  3. }
(128 real changes made)
(380 real changes made)
(1,156 real changes made)
(930 real changes made)
(167 real changes made)
(40 real changes made)
(53 real changes made)
(54 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreAL = 0

. gen count_nonzeroAL = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in srgayadopt sabortion srenvironment srimmigration sdeathpen swall sbordersec scrime {
  2.     replace total_scoreAL = total_scoreAL + `var'
  3.     replace count_nonzeroAL = count_nonzeroAL + (`var' != 0)
  4. }
(8,152 real changes made)
(8,152 real changes made)
(7,900 real changes made)
(7,900 real changes made)
(7,124 real changes made)
(7,124 real changes made)
(7,350 real changes made)
(7,350 real changes made)
(8,113 real changes made)
(8,113 real changes made)
(8,240 real changes made)
(8,240 real changes made)
(8,227 real changes made)
(8,227 real changes made)
(8,226 real changes made)
(8,226 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen libValues = .
(8,280 missing values generated)

. replace libValues = total_scoreAL / count_nonzeroAL if count_nonzeroAL > 0
(8,277 real changes made)

. 
. // Demographic variables
. * Delete missing values
. rename V201507x age 

. replace age = . if age == -9
(348 real changes made, 348 to missing)

. 
. rename V201617x income 

. replace income = . if inlist(income, -9, -5)
(616 real changes made, 616 to missing)

. 
. rename V201510 education 

. replace education = . if inlist(education, -9, -8, 95)
(131 real changes made, 131 to missing)

. 
. rename V201600 FemaleGender 

. replace FemaleGender = . if FemaleGender == -9
(67 real changes made, 67 to missing)

. 
. rename V201549x race

. replace race = . if inlist(race, -9, -8)
(102 real changes made, 102 to missing)

. 
. rename V201200 libconsp 

. replace libconsp = . if inlist(libconsp, -9, -8, 99)
(1,224 real changes made, 1,224 to missing)

. 
. *Create dummy and centred-squared variables
. gen Graduate=.
(8,280 missing values generated)

. replace Graduate=0 if education<6
(4,502 real changes made)

. replace Graduate=1 if inrange(education, 6, 8)
(3,647 real changes made)

. 
. egen age_centered = mean(age) 

. replace age_centered = age - age_centered
(8,280 real changes made, 348 to missing)

. gen age_centered_squared = age_centered^2
(348 missing values generated)

. 
. gen Unemployed = . 
(8,280 missing values generated)

. replace Unemployed = 1 if inlist(V201533x, 20, 40)
(384 real changes made)

. replace Unemployed = 0 if V201533x >= 0 & (V201533x < 20)
(5,132 real changes made)

. replace Unemployed = 0 if inlist(V201533x, 51, 61, 71, 81)
(345 real changes made)

. 
. gen Married=.
(8,280 missing values generated)

. replace Married=1 if V201508==1
(4,315 real changes made)

. replace Married=0 if inrange(V201508, 2, 6)
(3,909 real changes made)

. 
. //LifeSat
. *Delete missing values
. rename V201651 lifesat 

. replace lifesat = . if inlist(lifesat, -9, -8, -5)
(149 real changes made, 149 to missing)

. 
. *Now reverse, so happiness is coded high
. qui sum lifesat 

. local max_value = r(max)

. gen reversed_lifesat = `max_value' + 1 - lifesat
(149 missing values generated)

. 
. *Standardize from 1-2, so it's like other dependent variables in the book
. foreach var in reversed_lifesat {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
reversed_l~t |      8,131    3.530316    .9615791          1          5
(149 missing values generated)

. 
. rename sreversed_lifesat LifeSat

. 
. // Religious Attendance
. gen ReligiousAtt=. 
(8,280 missing values generated)

. replace ReligiousAtt=0 if V201454==-1
(7,036 real changes made)

. replace ReligiousAtt=1 if inlist(V201454, 1, 2)
(1,242 real changes made)

. 
. // Standardize variables
. egen Income = std(income)
(616 missing values generated)

. egen Age = std(age_centered_squared) 
(348 missing values generated)

. egen LibValues = std(libValues)
(3 missing values generated)

. egen SocJusValues = std(socJusValues)
(18 missing values generated)

. 
. regress LifeSat SocJusValues [pweight=V200010b], robust 
(sum of wgt is 7,341.8953060642)

Linear regression                               Number of obs     =      7,359
                                                F(1, 7357)        =     127.49
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0358
                                                Root MSE          =     .24147

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |  -.0482143   .0042701   -11.29   0.000    -.0565848   -.0398437
       _cons |   1.628839   .0042418   384.00   0.000     1.620524    1.637154
------------------------------------------------------------------------------

. eststo
(est1 stored)

. regress LifeSat SocJusValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight=V20001
> 0b], robust 
(sum of wgt is 5,119.94624529735)

Linear regression                               Number of obs     =      4,781
                                                F(8, 4772)        =      31.43
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0971
                                                Root MSE          =     .23489

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |  -.0346022   .0054225    -6.38   0.000    -.0452327   -.0239716
         Age |   .0034366   .0059415     0.58   0.563    -.0082114    .0150847
FemaleGender |  -.0192563    .010173    -1.89   0.058       -.0392    .0006875
    Graduate |   .0124036   .0102325     1.21   0.226    -.0076567    .0324639
      Income |   .0260137   .0068533     3.80   0.000     .0125781    .0394494
     Married |    .074487   .0119497     6.23   0.000     .0510601    .0979139
ReligiousAtt |   .0587845   .0157523     3.73   0.000     .0279027    .0896664
  Unemployed |  -.0986436   .0234224    -4.21   0.000    -.1445624   -.0527248
       _cons |   1.603199   .0176879    90.64   0.000     1.568522    1.637875
------------------------------------------------------------------------------

. eststo
(est2 stored)

. regress LifeSat LibValues [pweight=V200010b], robust 
(sum of wgt is 7,344.25555184377)

Linear regression                               Number of obs     =      7,361
                                                F(1, 7359)        =     190.65
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0453
                                                Root MSE          =     .24025

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   LibValues |  -.0544102   .0039406   -13.81   0.000    -.0621348   -.0466856
       _cons |   1.628029   .0041969   387.91   0.000     1.619801    1.636256
------------------------------------------------------------------------------

. eststo
(est3 stored)

. regress LifeSat LibValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight=V200010b]
> , robust 
(sum of wgt is 5,121.48759002772)

Linear regression                               Number of obs     =      4,782
                                                F(8, 4773)        =      38.47
                                                Prob > F          =     0.0000
                                                R-squared         =     0.1099
                                                Root MSE          =     .23319

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   LibValues |  -.0481225   .0051685    -9.31   0.000    -.0582552   -.0379899
         Age |   .0055578   .0059449     0.93   0.350     -.006097    .0172125
FemaleGender |  -.0243023   .0101022    -2.41   0.016    -.0441072   -.0044973
    Graduate |   .0244588   .0101976     2.40   0.017     .0044668    .0444507
      Income |   .0285211   .0067889     4.20   0.000     .0152117    .0418304
     Married |   .0707884   .0118635     5.97   0.000     .0475305    .0940463
ReligiousAtt |    .045058   .0160587     2.81   0.005     .0135756    .0765404
  Unemployed |  -.0986168   .0221439    -4.45   0.000     -.142029   -.0552045
       _cons |   1.610207   .0176442    91.26   0.000     1.575616    1.644798
------------------------------------------------------------------------------

. eststo
(est4 stored)

. regress LifeSat SocJusValues LibValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pwei
> ght=V200010b], robust 
(sum of wgt is 5,119.94624529735)

Linear regression                               Number of obs     =      4,781
                                                F(9, 4771)        =      34.43
                                                Prob > F          =     0.0000
                                                R-squared         =     0.1100
                                                Root MSE          =     .23323

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |  -.0042836   .0085507    -0.50   0.616    -.0210469    .0124797
   LibValues |  -.0450088   .0084372    -5.33   0.000    -.0615495    -.028468
         Age |   .0055956    .005936     0.94   0.346    -.0060418    .0172329
FemaleGender |  -.0232683   .0100872    -2.31   0.021     -.043044   -.0034927
    Graduate |   .0244445   .0102039     2.40   0.017     .0044402    .0444489
      Income |   .0283074   .0067917     4.17   0.000     .0149926    .0416222
     Married |   .0705878   .0118995     5.93   0.000     .0472593    .0939163
ReligiousAtt |   .0453878   .0160464     2.83   0.005     .0139294    .0768462
  Unemployed |  -.0985531   .0222331    -4.43   0.000    -.1421402   -.0549661
       _cons |   1.608774   .0176779    91.00   0.000     1.574117    1.643431
------------------------------------------------------------------------------

. eststo
(est5 stored)

. esttab

--------------------------------------------------------------------------------------------
                      (1)             (2)             (3)             (4)             (5)   
                  LifeSat         LifeSat         LifeSat         LifeSat         LifeSat   
--------------------------------------------------------------------------------------------
SocJusValues      -0.0482***      -0.0346***                                     -0.00428   
                 (-11.29)         (-6.38)                                         (-0.50)   

Age                               0.00344                         0.00556         0.00560   
                                   (0.58)                          (0.93)          (0.94)   

FemaleGender                      -0.0193                         -0.0243*        -0.0233*  
                                  (-1.89)                         (-2.41)         (-2.31)   

Graduate                           0.0124                          0.0245*         0.0244*  
                                   (1.21)                          (2.40)          (2.40)   

Income                             0.0260***                       0.0285***       0.0283***
                                   (3.80)                          (4.20)          (4.17)   

Married                            0.0745***                       0.0708***       0.0706***
                                   (6.23)                          (5.97)          (5.93)   

ReligiousAtt                       0.0588***                       0.0451**        0.0454** 
                                   (3.73)                          (2.81)          (2.83)   

Unemployed                        -0.0986***                      -0.0986***      -0.0986***
                                  (-4.21)                         (-4.45)         (-4.43)   

LibValues                                         -0.0544***      -0.0481***      -0.0450***
                                                 (-13.81)         (-9.31)         (-5.33)   

_cons               1.629***        1.603***        1.628***        1.610***        1.609***
                 (384.00)         (90.64)        (387.91)         (91.26)         (91.00)   
--------------------------------------------------------------------------------------------
N                    7359            4781            7361            4782            4781   
--------------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.1.log
  log type:  text
 closed on:  12 May 2025, 17:45:21
---------------------------------------------------------------------------------------------------------------
